package com.li.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.li.entity.PageResult;
import com.li.entity.QueryPageBean;
import com.li.mapper.LogMapper;
import com.li.pojo.CheckItem;
import com.li.pojo.Log;
import com.li.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = LogService.class)
@Transactional
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    // 分页查询日志
    public PageResult selectPageByCondition(QueryPageBean queryPageBean) {
        //分页查询
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        //通过条件进行分页查询
        Page<Log> logs = logMapper.selectPageByCondition(queryPageBean.getQueryString());
        //获取结果
        PageResult pageResult = new PageResult();

        pageResult.setRows(logs.getResult());
        pageResult.setTotal(logs.getTotal());
        return pageResult;
    }

    // 删除日志
    public void deleteById(Integer id) {
        logMapper.deleteById(id);
    }

    // 保存日志
    public void save(Log log) {
        logMapper.save(log);
    }
}
